<?php
class AppModel extends Model {
    public function serverToClientTime ($datetime, $format='Y-m-d H:i:s') {
        date_default_timezone_set(SERVER_TIMEZONE); // switch to server timezone first

        $datetimeObject = date_create($datetime); // create datetime object
        $clientTimezone = timezone_open(CLIENT_TIMEZONE); // create client timezone object

        date_timezone_set($datetimeObject, $clientTimezone); // switch datetime object follow client timezone

        return date_format($datetimeObject, $format);
    } // serverToClientTime

    public function format_id ($id, $figure=6) {
        $len = strlen($id);

        if ($len >= $figure) {
            return $pre.$id;
        }

        $zero = '';
        $loop = $figure - $len;

        for ($x=0; $x<$loop; $x++) {
            $zero .= '0';
        }

        return $zero.$id;
    } // format_id
} // AppModel
?>